/**   
 * @Title: BorderImageView.java
 * @Package com.practices.view
 * @Description: TODO
 * @author woailuo 
 * @date 2013-6-12 下午10:57:03
 * @version V1.0   
 */
package com.practices.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.ImageView;

/**
 * @ClassName: BorderImageView
 * @Description: TODO
 * @author woailuo
 * @date 2013-6-12 下午10:57:03
 * 
 */
public class BorderImageView extends ImageView {
	private Paint mPaint;
	private int borderWidth;
	private int color;

	public int getBorderWidth() {
		return borderWidth;
	}

	public void setBorderWidth(int borderWidth) {
		this.borderWidth = borderWidth;
	}

	public int getColor() {
		return color;
	}

	public void setColor(int color) {
		this.color = color;
	}

	public BorderImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
		initPaint();
	}

	private void initPaint() {
		mPaint = new Paint();
		// 设置边框颜色
		mPaint.setColor(color);
		mPaint.setStyle(Paint.Style.STROKE);
		// 设置边框宽度
		mPaint.setStrokeWidth(borderWidth);
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		Rect rect = canvas.getClipBounds();
		rect.bottom--;
		rect.right--;
		canvas.drawRect(rect, mPaint);
	}

}
